package br.com.iplant.mb;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import br.com.iplant.dao.FornecedorDAO;
import br.com.iplant.vo.Fornecedor;


public class CadastroFornecedor extends JPanel {

	private JPanel contentPane;
	private JTextField tfNome;
	private JTextField tfDescricao;
	private JTextField tfCnpj;
	private JTextField tfInscEstadual;
	private JLabel lblEndreo;
	private JTextField tfEndereo;
	private JLabel lblCidade;
	private JTextField tfCidade;
	private JLabel lblUf;
	private JTextField tfUf;
	private JLabel lblCep;
	private JTextField tfCep;
	private JLabel lblContato1;
	private JLabel lblContato2;
	private JLabel lblContato3;
	private JLabel lblContato4;
	private JTextField tfContato1;
	private JTextField tfContato2;
	private JTextField tfContato3;
	private JTextField tfContato4;
	private JLabel lblTel1;
	private JLabel lblTel2;
	private JLabel lblTel3;
	private JLabel lblTel4;
	private JTextField tfTel1;
	private JTextField tfTel2;
	private JTextField tfTel3;
	private JTextField tfTel4;
	private JLabel lblEmail1;
	private JLabel lblEmail2;
	private JLabel lblEmail3;
	private JLabel lblEmail4;

	Fornecedor fornecedor = new Fornecedor();
	FornecedorDAO fornecedorDao = new FornecedorDAO();
	private JTextField tfEmail1;
	private JTextField tfEmail2;
	private JTextField tfEmail3;
	private JTextField tfEmail4;
	
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CadastroFornecedor frame = new CadastroFornecedor();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public CadastroFornecedor() {
		
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		
		contentPane.setLayout(null);
		
		JLabel lblNome = new JLabel("Nome:");
		lblNome.setBounds(10, 11, 46, 14);
		contentPane.add(lblNome);
		
		JLabel lblDescricao = new JLabel("Descri\u00E7\u00E3o:");
		lblDescricao.setBounds(218, 12, 52, 14);
		contentPane.add(lblDescricao);
		
		JLabel lblCnpj = new JLabel("Cnpj:");
		lblCnpj.setBounds(10, 53, 46, 14);
		contentPane.add(lblCnpj);
		
		tfNome = new JTextField();
		tfNome.setText("Supermaia Ltda");
		tfNome.setBounds(10, 29, 204, 20);
		contentPane.add(tfNome);
		tfNome.setColumns(10);
		
		tfDescricao = new JTextField();
		tfDescricao.setText("Supermerdado");
		tfDescricao.setBounds(218, 29, 206, 20);
		contentPane.add(tfDescricao);
		tfDescricao.setColumns(10);
		
		tfCnpj = new JTextField();
		tfCnpj.setText("00.000.000/0000-00");
		tfCnpj.setBounds(10, 71, 204, 20);
		contentPane.add(tfCnpj);
		tfCnpj.setColumns(10);
		
		JLabel lblInscrioEstadual = new JLabel("Inscri\u00E7\u00E3o Estadual:");
		lblInscrioEstadual.setBounds(218, 53, 97, 14);
		contentPane.add(lblInscrioEstadual);
		
		tfInscEstadual = new JTextField();
		tfInscEstadual.setText("00.000.000/000-00");
		tfInscEstadual.setBounds(218, 71, 134, 20);
		contentPane.add(tfInscEstadual);
		tfInscEstadual.setColumns(10);
		
		lblEndreo = new JLabel("Endre\u00E7o:");
		lblEndreo.setBounds(10, 95, 46, 14);
		contentPane.add(lblEndreo);
		
		tfEndereo = new JTextField();
		tfEndereo.setText("Qnm 20 Conj L Casa 33");
		tfEndereo.setBounds(10, 113, 139, 20);
		contentPane.add(tfEndereo);
		tfEndereo.setColumns(10);
		
		lblCidade = new JLabel("Cidade:");
		lblCidade.setBounds(154, 95, 46, 14);
		contentPane.add(lblCidade);
		
		tfCidade = new JTextField();
		tfCidade.setText("Ceilandia ");
		tfCidade.setBounds(154, 113, 128, 20);
		contentPane.add(tfCidade);
		tfCidade.setColumns(10);
		
		lblUf = new JLabel("Uf:");
		lblUf.setBounds(288, 95, 20, 14);
		contentPane.add(lblUf);
		
		tfUf = new JTextField();
		tfUf.setText("DF");
		tfUf.setBounds(288, 113, 46, 20);
		contentPane.add(tfUf);
		tfUf.setColumns(10);
		
		lblCep = new JLabel("Cep:");
		lblCep.setBounds(338, 95, 46, 14);
		contentPane.add(lblCep);
		
		tfCep = new JTextField();
		tfCep.setText("72000000");
		tfCep.setBounds(338, 113, 86, 20);
		contentPane.add(tfCep);
		tfCep.setColumns(10);
		
		lblContato1 = new JLabel("Contato 1:");
		lblContato1.setBounds(10, 141, 58, 14);
		contentPane.add(lblContato1);
		
		lblContato2 = new JLabel("Contato 2:");
		lblContato2.setBounds(10, 163, 58, 14);
		contentPane.add(lblContato2);
		
		lblContato3 = new JLabel("Contato 3:");
		lblContato3.setBounds(10, 185, 58, 14);
		contentPane.add(lblContato3);
		
		lblContato4 = new JLabel("Contato 4:");
		lblContato4.setBounds(10, 206, 58, 14);
		contentPane.add(lblContato4);
		
		tfContato1 = new JTextField();
		tfContato1.setText("Aminadabes");
		tfContato1.setBounds(63, 138, 86, 20);
		contentPane.add(tfContato1);
		tfContato1.setColumns(10);
		
		tfContato2 = new JTextField();
		tfContato2.setText("Aminadabes");
		tfContato2.setBounds(64, 160, 86, 20);
		contentPane.add(tfContato2);
		tfContato2.setColumns(10);
		
		tfContato3 = new JTextField();
		tfContato3.setText("Aminadabes");
		tfContato3.setBounds(64, 182, 86, 20);
		contentPane.add(tfContato3);
		tfContato3.setColumns(10);
		
		tfContato4 = new JTextField();
		tfContato4.setText("Aminadabes");
		tfContato4.setBounds(64, 203, 86, 20);
		contentPane.add(tfContato4);
		tfContato4.setColumns(10);
		
		lblTel1 = new JLabel("Tel.1");
		lblTel1.setBounds(162, 141, 30, 14);
		contentPane.add(lblTel1);
		
		lblTel2 = new JLabel("Tel.2");
		lblTel2.setBounds(162, 163, 30, 14);
		contentPane.add(lblTel2);
		
		lblTel3 = new JLabel("Tel.3");
		lblTel3.setBounds(162, 185, 30, 14);
		contentPane.add(lblTel3);
		
		lblTel4 = new JLabel("Tel.4");
		lblTel4.setBounds(162, 206, 30, 14);
		contentPane.add(lblTel4);
		
		tfTel1 = new JTextField();
		tfTel1.setText("(61) 34426211");
		tfTel1.setBounds(201, 138, 86, 20);
		contentPane.add(tfTel1);
		tfTel1.setColumns(10);
		
		tfTel2 = new JTextField();
		tfTel2.setText("(61) 34426211");
		tfTel2.setBounds(201, 160, 86, 20);
		contentPane.add(tfTel2);
		tfTel2.setColumns(10);
		
		tfTel3 = new JTextField();
		tfTel3.setText("(61) 34426211");
		tfTel3.setBounds(201, 182, 86, 20);
		contentPane.add(tfTel3);
		tfTel3.setColumns(10);
		
		tfTel4 = new JTextField();
		tfTel4.setText("(61) 34426211");
		tfTel4.setBounds(201, 203, 86, 20);
		contentPane.add(tfTel4);
		tfTel4.setColumns(10);
		
		lblEmail1 = new JLabel("Email");
		lblEmail1.setBounds(296, 141, 30, 14);
		contentPane.add(lblEmail1);
		
		lblEmail2 = new JLabel("Email");
		lblEmail2.setBounds(296, 163, 30, 14);
		contentPane.add(lblEmail2);
		
		lblEmail3 = new JLabel("Email");
		lblEmail3.setBounds(296, 185, 30, 14);
		contentPane.add(lblEmail3);
		
		lblEmail4 = new JLabel("Email");
		lblEmail4.setBounds(296, 206, 30, 14);
		contentPane.add(lblEmail4);
		
		tfEmail1 = new JTextField();
		tfEmail1.setBounds(338, 138, 86, 20);
		contentPane.add(tfEmail1);
		tfEmail1.setColumns(10);
		
		tfEmail2 = new JTextField();
		tfEmail2.setBounds(338, 160, 86, 20);
		contentPane.add(tfEmail2);
		tfEmail2.setColumns(10);
		
		tfEmail3 = new JTextField();
		tfEmail3.setBounds(338, 182, 86, 20);
		contentPane.add(tfEmail3);
		tfEmail3.setColumns(10);
		
		tfEmail4 = new JTextField();
		tfEmail4.setBounds(338, 203, 86, 20);
		contentPane.add(tfEmail4);
		tfEmail4.setColumns(10);
		
		JButton btnSalvar = new JButton("Salvar");
		btnSalvar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
				fornecedor.setNome(tfNome.getText());
				fornecedor.setDescricao(tfDescricao.getText());
				fornecedor.setCnpj(tfCnpj.getText());
				fornecedor.setInscricaoEstadual(tfInscEstadual.getText());
				fornecedor.setEndereco(tfEndereo.getText());
				fornecedor.setCep(tfCep.getText());
				fornecedor.setCidade(tfCidade.getText());
				fornecedor.setUf(tfUf.getText());
				fornecedor.setContato1(tfContato1.getText());
				fornecedor.setTelefone1(tfTel1.getText());
				fornecedor.setEmail1(tfEmail1.getText());
				fornecedor.setContato2(tfContato2.getText());
				fornecedor.setTelefone1(tfTel2.getText());
				fornecedor.setEmail1(tfEmail2.getText());
				fornecedor.setContato3(tfContato3.getText());
				fornecedor.setTelefone1(tfTel3.getText());
				fornecedor.setEmail1(tfEmail3.getText());
				fornecedor.setContato3(tfContato4.getText());
				fornecedor.setTelefone1(tfTel4.getText());
				fornecedor.setEmail1(tfEmail4.getText());
				
				fornecedorDao.salvar(fornecedor);
			}
		});
		btnSalvar.setBounds(63, 231, 89, 23);
		contentPane.add(btnSalvar);
		
		JButton btnFechar = new JButton("Fechar");
		btnFechar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		btnFechar.setBounds(335, 231, 89, 23);
		contentPane.add(btnFechar);
		
		
	}
}
